package com.huangmb.anymark.app.net;

import com.alibaba.fastjson.JSON;
import com.huangmb.androidlib.utils.Logger;

/**
 * @author hmb
 * @version 1.0
 * @since 2016/4/16 15:45
 */
public class Response {
    private static final String TAG = Response.class.getSimpleName();
    private int errorCode = -1;
    private String errorMessage;
    private String result;

    public Response(){

    }
    public Response(int code,String msg,String result){
        this.errorCode = code;
        this.errorMessage = msg;
        this.result = result;
    }
    public static Response parse(String response){
        try{
            return JSON.parseObject(response,Response.class);
        }catch (Exception e){
            Logger.d(TAG,"json 解析异常",e);
            return null;
        }

    }

    public boolean hasError(){
        return errorCode != 0;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }
}
